package com.health.mapper;

import com.health.entity.Admin;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.health.entity.pojo.dto.AdminDTO;
import com.health.entity.pojo.dto.DeleteAdminShelvesMultiDTO;
import com.health.entity.pojo.vo.AdminVO;
import com.health.entity.pojo.vo.QueryAdminVO;
import com.health.service.IHospitalService;
import org.apache.ibatis.annotations.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;

import java.util.List;

/**
 * <p>
 * 后台管理员表 Mapper 接口
 * </p>
 *
 * @author sanchuan
 * @since 2023-04-14
 */
public interface AdminMapper extends BaseMapper<Admin> {
    @Select("SELECT a.id,a.username,a.avatar,a.is_look,a.name,d.roles FROM " +
            "admin a,t_department d WHERE a.department_id = d.id AND username = #{token}")
    AdminVO findUserInfo(String token);

    List<QueryAdminVO> listAdminPage(@Param("adminDTO") AdminDTO adminDTO);

    @Insert("INSERT INTO `t_admin_role` VALUE(#{aid},#{rid})")
    Boolean saveAdminRole(@Param("aid") Integer aid, @PathVariable("rid") Integer rid);

    @Update("UPDATE `t_admin_role` SET rid = #{rid} WHERE aid = #{aid}")
    Boolean upadteAdminRole(@Param("aid") Integer aid, @PathVariable("rid") Integer rid);

    @Delete("delete from `t_admin_role` where aid = #{id} and rid = #{rid}")
    Boolean deleteAdminRole(@Param("id") Integer id, @Param("rid") Integer rid);

    Boolean deleteAdminRoleMulti(@Param("selectedData") List<DeleteAdminShelvesMultiDTO> selectedData);
}
